﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using OgilvyOne.UKNow.DAL;
using OgilvyOne.UKNow.Mobile.Model.Events;
using ECCIT.Extension.Weibo_v2.Common;
using OgilvyOne.UKNow.Mobile.Utilities;

namespace OgilvyOne.UKNow.Mobile.APIs.Events
{
    public class IsCheckedIn : IHttpHandler
    {
        public bool IsReusable { get { return true; } }

        public void ProcessRequest(HttpContext context)
        {
            try
            {
                int uid = Convert.ToInt32(context.Request.Params["uid"].ToString());
                int eventid = Convert.ToInt32(context.Request.Params["eventid"].ToString());

                MemberCheckInDAL mca = new MemberCheckInDAL();
                bool checkedIn = mca.IsCheckIn(uid, eventid);
                string msg = (checkedIn) ? "用户已签到" : "用户未签到";
                context.Response.Write(ResultUtility.ReturnResultJson("0", "{" + String.Format("\"flag\":\"{0}\"", checkedIn) + "}", msg));
            }
            catch (Exception ex)
            {
                context.Response.Write(ResultUtility.ReturnResultJson("-680", "", "获取用户签到信息失败"));
            }

        }
    }
}
